
Function.prototype.Myapply = function (context = window, args) {
    if (typeof this !== 'function') {  // 加上判断，调用Mycall 的是否是一个function
        throw new TypeError('Type Error');
    }
    let fn = Symbol('fn');
    // console.log(context) 
    context[fn] = this;
    const result = context[fn](...args);
    delete context[fn];
    return result;
}

let obj = {
    name: 'qaq',
    age: 18
}

let say = function (a, b, c, d) {
    console.log(this.name);
    console.log(this.age);
    // console.log(test[0]);
    console.log(a);
    console.log(b);
    console.log(c);
    console.log(d);
}

console.log(say.Myapply(obj, [1234, 123, 12, 1]));

